package com.jauto.auto;

import com.jauto.auto.core.Device;
import com.jauto.auto.core.Devices;
import com.jauto.auto.core.Node;


import java.sql.Time;
import java.util.List;
import java.util.Timer;

/**
 * 〈功能概述〉<br>
 *
 * @className: Test
 * @package: com.java.auto
 * @author: zhangRenHuo
 * @date: 2020/8/5 10:10
 */
public class Test {
    public static void main(String[] args)throws Exception{

//        FirefoxDriver firefoxDriver = new FirefoxDriver();
//        firefoxDriver.get("https://xm.58.com/shengyizr/?PGTID=0d100000-0025-ee13-99ec-f8c541411248&ClickID=2");
//        List<WebElement> lis = firefoxDriver.findElementsByXPath("/html/body/div[5]/div[5]/div[1]/ul/li");
//
//        for (WebElement li : lis){
//            WebElement element = li.findElement(By.xpath("h2/a/span"));
//            String name = element.getText();
//            println(name);
//        }

        List<Device> devices = Devices.getDevices();
        Device device = devices.get(0);
        println(device.getAndroidId());

//        device.click(1238,1398,1412,1572);
//        List<Node> nodes = device.find().desc("^评论.*").getNodes();
//        if (null != nodes){
//            nodes.get(0).click();
//        }
        List<Node> nodeList = device.find().className("androidx.viewpager.widget.ViewPager").getNodes();

        nodeList.stream().map(item->{
            println(item.getBounds());
            return item;
        });

//        List<Node> nodes = device.find().id("com.tencent.mm:id/ef9").getNodes();
//        if (null != nodes){
//            nodes.get(0).click();
//        }
//
//        List<Node> nodes1 = device.find().text("扫一扫").getNodes();
//        if (null != nodes1){
//            nodes1.get(0).click();
//        }
//
//        List<Node> nodes2 = device.find().id("com.tencent.mm:id/fah").getNodes();
//        if (null != nodes2){
//            nodes2.get(0).click();
//        }

    }

    public static void println(String str){
        System.out.println(str);
    }
}
